//http.ClientRequest    
const http = require('http');
const querystring = require('querystring');
let data = querystring.stringify({ name: 'John中国' });

const options = {
    hostname: 'localhost',
    port: 3000,
    path: '/',
    method: 'GET',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': Buffer.byteLength(data)
    }
};
let req = http.request(options, (res) => {
    console.log(`headers: ${JSON.stringify(res.headers)}`)
    res.on('data', (chunk) => {
        console.log(`chunk: ${chunk}`)
    });
    res.on('end', () => {
        console.log('end')
    });

})
req.on('error', (e) => {
    console.error(`请求遇到问题: ${e.message}`);
});

req.write(data);
req.end();

